



from tkinter import *
from tkinter import messagebox
from PIL import Image, ImageTk

root = Tk()

# Бес-полезная фигня которая нужна только для того чтобы занять место
def bt_input_a():
    try:
        a_in = int(input_a.get())
        print(a_in)
    except ValueError:
        messagebox.showerror(title='invalid number A', message='invalid number A')


def bt_input_b():
    try:
        b_in = int(input_b.get())
        print(b_in)
    except ValueError:
        messagebox.showerror(title='invalid number B', message='invalid number B')

def bt_input_c():
    try:
        c_in = int(input_c.get())
        print(c_in)
    except ValueError:
        messagebox.showerror(title='invalid number C', message='invalid number C')

def bt_input_x():
    try:
        x_in = int(input_x.get())
        print(x_in)
    except ValueError:
        messagebox.showerror(title='invalid number X', message='invalid number X')

def bt_input_y():
    try:
        y_in = int(input_y.get())
        print(y_in)
    except ValueError:
        messagebox.showerror(title='invalid number Y', message='invalid number Y')
#________________________________________________________________________


def Calculate():
    try:
        a = int(input_a.get())
        error_i = "ok"
    except ValueError:
        error_i = "error"
        messagebox.showerror(title='invalid number A', message='invalid number A')
    try:
        b = int(input_b.get())
        error_i = "ok"
    except ValueError:
        error_i = "error"
        messagebox.showerror(title='invalid number B', message='invalid number B')
    try:
        c = int(input_c.get())
        error_i = "ok"
    except ValueError:
        error_i = "error"
        messagebox.showerror(title='invalid number C', message='invalid number C')
    try:
        x = int(input_x.get())
        error_i = "ok"
    except ValueError:
        error_i = "error"
        messagebox.showerror(title='invalid number X', message='invalid number X')
    try:
        y = int(input_y.get())
        error_i = "ok"
    except ValueError:
        error_i = "error"
        messagebox.showerror(title='invalid number Y', message='invalid number Y')

    print(error_i)

    if str(error_i) != "error":

        if a > c:
            a,c=c,a
        elif b > c:
            b,c=c,b
        elif a > b:
            a,b=b,a
        elif x > y:
            x,y=y,x

        print("\n")
        print(a)
        print(b)
        print(c)
        print(x)
        print(y)
        print("\n")

        resulte = str("YES" if a <= x and b <= y else "NO")

        messagebox.showinfo(title="resulte", message=resulte)

        print(resulte)

    else:
        pass


def Calculate_fish():

    try:
        box_m = int(input_box.get())
        error_f = "ok"
    except ValueError:
        error_f = "error"
        messagebox.showerror(title='invalid number box', message='invalid number BOX')
    try:
        fish_d = int(input_fish.get())
        error_f = "ok"
    except ValueError:
        error_f = "error"
        messagebox.showerror(title='invalid number fish', message='invalid number fish')

    print(error_f)

    if error_f != "error":

        R = fish_d/2
        V_FISH = 4/3*3.14159*R**3
        V_BOX = box_m**3

        resulte_fish_n = 100-(100*(V_BOX-V_FISH)/V_BOX)
        resulte_fish = f"resulte fish: {resulte_fish_n}%"
        if resulte_fish_n > 100:
            messagebox.showerror(title='invalid', message=f'{resulte_fish}\nТсссс, слышишь?. Физика и Математика перематерились.')
        else:
            print(resulte_fish)
            messagebox.showinfo(title="resulte", message=resulte_fish)

    else:
        pass





root['bg'] = '#fafafa'
root.title('КИРПИЧ, РЫБА и Коробка')

root.geometry('400x450')
root.resizable(width=False, height=False)

ico = Image.open('icon.ico')
photo = ImageTk.PhotoImage(ico)
root.wm_iconphoto(False, photo)

image = PhotoImage(file = "background.png")
image_bg = Label(root, image=image)
image_bg.place(x=0,y=0, relwidth=1, relheight=1)

#__________________ TEXT
label_input_fish = Label(root, text="fish", bg='#75afd2')
label_input_fish.place(x=250, y=250, width=50, height=20)

label_input_box = Label(root, text="box", bg='#75afd2')
label_input_box.place(x=305, y=250, width=50, height=20)
#_______________________________________________________
#__________________ INPUT
input_a = Entry(root, bg='#75afd2')
input_a.place(x=250, y=20, width=50, height=20)

input_b = Entry(root, bg='#75afd2')
input_b.place(x=250, y=45, width=50, height=20)

input_c = Entry(root, bg='#75afd2')
input_c.place(x=250, y=70, width=50, height=20)

input_x = Entry(root, bg='#75afd2')
input_x.place(x=250, y=95, width=50, height=20)

input_y = Entry(root, bg='#75afd2')
input_y.place(x=250, y=120, width=50, height=20)

input_fish = Entry(root, bg='#75afd2')
input_fish.place(x=250, y=225, width=50, height=20)

input_box = Entry(root, bg='#75afd2')
input_box.place(x=305, y=225, width=50, height=20)
#_______________________________________________________
#__________________ BUTTON
bt_1_a = Button(root, text='set-a', bg='#75afd2', command=bt_input_a).place(x=305, y=20, width=50, height=20)

bt_1_b = Button(root, text='set-b', bg='#75afd2', command=bt_input_b).place(x=305, y=45, width=50, height=20)

bt_1_c = Button(root, text='set-c', bg='#75afd2', command=bt_input_c).place(x=305, y=70, width=50, height=20)

bt_1_x = Button(root, text='set-x', bg='#75afd2', command=bt_input_x).place(x=305, y=95, width=50, height=20)

bt_1_y = Button(root, text='set-y', bg='#75afd2', command=bt_input_y).place(x=305, y=120, width=50, height=20)

bt_calculate = Button(root, text='Calculate', bg='#8a51af', command=Calculate).place(x=250, y=150, width=105, height=20)

fish_calculate = Button(root, text='Calculate', bg='#8a51af', command=Calculate_fish).place(x=250, y=275, width=105, height=20)
#_______________________________________________________


root.mainloop()



